package com.tjsinfo.tjsoa.vote.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.vote.bo.ITVoteColumnBO;
import com.tjsinfo.tjsoa.vote.bo.ITVoteConformationBO;
import com.tjsinfo.tjsoa.vote.bo.ITVoteEstimatedBO;
import com.tjsinfo.tjsoa.vote.bo.ITVoteHeadBO;
import com.tjsinfo.tjsoa.vote.vo.TVoteColumn;
import com.tjsinfo.tjsoa.vote.vo.TVoteConformation;
import com.tjsinfo.tjsoa.vote.vo.TVoteEstimated;
import com.tjsinfo.tjsoa.vote.vo.TVoteHead;

public class VoteBrowseAction extends Action {
	private ITVoteHeadBO headBo;
	private ITVoteColumnBO columnBo;
	private ITVoteConformationBO conformationBo;
	private ITVoteEstimatedBO estimatedBo;
	public void setEstimatedBo(ITVoteEstimatedBO estimatedBo) {
		this.estimatedBo = estimatedBo;
	}
	public void setHeadBo(ITVoteHeadBO headBo) {
		this.headBo = headBo;
	}	
	public void setColumnBo(ITVoteColumnBO columnBo) {
		this.columnBo = columnBo;
	}
	public void setConformationBo(ITVoteConformationBO conformationBo) {
		this.conformationBo = conformationBo;
	}

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			String headId = request.getParameter("headId");
			
			List<TVoteColumn> columnLists = columnBo.find(headId);
			List<TVoteConformation> conformationParentLists = conformationBo.findBy(headId);
			List<TVoteConformation> conformationLists = conformationBo.find(headId);
			List<TVoteEstimated> estimatedLists = estimatedBo.find(headId);
			TVoteHead head = headBo.findById(headId);
			

			request.setAttribute("columnLists", columnLists);
			request.setAttribute("conformationParentLists", conformationParentLists);
			request.setAttribute("conformationLists", conformationLists);
			request.setAttribute("estimatedLists", estimatedLists);
			request.setAttribute("head", head);
			
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("failed");
		}
	}

}

